import time
import socket 
import json
import requests
import struct
from datetime import datetime


class TInfluxDB:
    def __init__(self) -> None:
        self.host="meeting.xmgkfw.com"
        self.port = 42036
        self.token  = "Basic cm9vdDpoaHVjMTExNQ=="
        self.db = "pcs2023"
    def writeDatapoints(self , dataPoints ):
        try:
            headers = {
                "Authorization" : self.token,
                'Content-Type': 'application/json',
            }
            influxdb_url= "http://"+self.host+":"+str(self.port) + '/write?db='+self.db            
            resp = requests.post(url=influxdb_url , headers=headers , data=dataPoints)
            print(resp)
        except Exception as er:
            print(er)

class TModbusCollecter:
    def __init__(self) -> None:
        self.host = "192.168.251.51"
        self.port = 502
        self.influxDBClient = TInfluxDB()
        self.dbHost="meeting.xmgkfw.com"
        self.dbPort = 42000
        self.dbBucket = "pcs_2023"
        self.dbMeasurement = "t_pcs8" 
        self.dbToken ="5h7gxpAJdb98PI3cZQv8X9WQU48Xbz7_Ey_vAWveXXx9HMMkYQwtn7-ZCjUU_-UTZQFQdSP3l46oosTUgzk-gA=="
        self.dbOrg = "kanshi"
        self.skt = None 
        self.registers={}
        self.cmdNo =0 
        self.valueFilePath="D:/project/pcs2023data"
        self.tasks=[{"unit":1,"code":4,"start":2255,"count":2},{"unit":1,"code":4,"start":2261,"count":14},{"unit":1,"code":4,"start":2381,"count":2},{"unit":1,"code":4,"start":4007,"count":2},{"unit":1,"code":4,"start":4011,"count":2},{"unit":1,"code":3,"start":5001,"count":16},{"unit":1,"code":4,"start":7201,"count":3},{"unit":1,"code":4,"start":7207,"count":2},{"unit":1,"code":4,"start":7300,"count":29},{"unit":1,"code":4,"start":7333,"count":4},{"unit":1,"code":4,"start":7341,"count":6},{"unit":1,"code":4,"start":7400,"count":6},{"unit":2,"code":4,"start":3,"count":2},{"unit":2,"code":4,"start":34,"count":37}]
        self.dpList = [{"regKey":"1_2255","dpId":5,"unitId":1,"regNo":2255,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"电池类型","dpDesc":"1:铅酸电池；2:锂电池","enbaleFlag":1},{"regKey":"1_2256","dpId":6,"unitId":1,"regNo":2256,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"电池容量","dpDesc":"大于0","enbaleFlag":1},{"regKey":"1_2261","dpId":7,"unitId":1,"regNo":2261,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"电池浮充电压","dpDesc":"\"200.0~800.0V","enbaleFlag":1},{"regKey":"1_2262","dpId":8,"unitId":1,"regNo":2262,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"电池均充电压","dpDesc":"\"200.0~800.0V","enbaleFlag":1},{"regKey":"1_2263","dpId":9,"unitId":1,"regNo":2263,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"均充转浮充电流","dpDesc":"\"0~125.0A","enbaleFlag":1},{"regKey":"1_2264","dpId":10,"unitId":1,"regNo":2264,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"最大充电电流","dpDesc":"\"0~125.0A","enbaleFlag":1},{"regKey":"1_2265","dpId":11,"unitId":1,"regNo":2265,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"最大放电电流","dpDesc":"\"0~125.0A","enbaleFlag":1},{"regKey":"1_2266","dpId":12,"unitId":1,"regNo":2266,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"电池电压保护上限","dpDesc":"\"200.0~800.0V","enbaleFlag":1},{"regKey":"1_2267","dpId":13,"unitId":1,"regNo":2267,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"电池电压保护下限","dpDesc":"\"200.0~800.0V","enbaleFlag":1},{"regKey":"1_2268","dpId":14,"unitId":1,"regNo":2268,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"BMS最大充电电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_2269","dpId":15,"unitId":1,"regNo":2269,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"BMS最大充电电流","dpDesc":"","enbaleFlag":1},{"regKey":"1_2270","dpId":16,"unitId":1,"regNo":2270,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"BMS放电截止电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_2271","dpId":17,"unitId":1,"regNo":2271,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"BMS放电最大电流","dpDesc":"","enbaleFlag":1},{"regKey":"1_2272","dpId":18,"unitId":1,"regNo":2272,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"EOD电压","dpDesc":"200.0~800.0V","enbaleFlag":1},{"regKey":"1_2273","dpId":19,"unitId":1,"regNo":2273,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"并网DOD","dpDesc":"0~100","enbaleFlag":1},{"regKey":"1_2274","dpId":20,"unitId":1,"regNo":2274,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"离网DOD","dpDesc":"0~100","enbaleFlag":1},{"regKey":"1_2381","dpId":21,"unitId":1,"regNo":2381,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"有功功率","dpDesc":"\"-30.0~30.0kW","enbaleFlag":1},{"regKey":"1_2382","dpId":22,"unitId":1,"regNo":2382,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"无功功率","dpDesc":"-30.0~30.0kVar","enbaleFlag":1},{"regKey":"1_4007","dpId":23,"unitId":1,"regNo":4007,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"电压体制","dpDesc":"\"关机状态下有效 M380V_OUTM=10","enbaleFlag":1},{"regKey":"1_4008","dpId":24,"unitId":1,"regNo":4008,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"频率体制","dpDesc":"\"关机状态下有效 FRE_50HZ=0","enbaleFlag":1},{"regKey":"1_4011","dpId":25,"unitId":1,"regNo":4011,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"串口波特率","dpDesc":"","enbaleFlag":1},{"regKey":"1_4012","dpId":26,"unitId":1,"regNo":4012,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"通信地址","dpDesc":"","enbaleFlag":1},{"regKey":"1_5001","dpId":27,"unitId":1,"regNo":5001,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-故障状态","dpDesc":"","enbaleFlag":1},{"regKey":"1_5001","dpId":28,"unitId":1,"regNo":5001,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-告警状态","dpDesc":"","enbaleFlag":1},{"regKey":"1_5001","dpId":29,"unitId":1,"regNo":5001,"byteNo":0,"bitNo":3,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom3-并网状态","dpDesc":"1-并网，0-无效","enbaleFlag":1},{"regKey":"1_5001","dpId":30,"unitId":1,"regNo":5001,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom4-离网状态","dpDesc":"1-离网，0-无效","enbaleFlag":1},{"regKey":"1_5001","dpId":31,"unitId":1,"regNo":5001,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom5-环境温度","dpDesc":"1-告警，0-正常","enbaleFlag":1},{"regKey":"1_5001","dpId":32,"unitId":1,"regNo":5001,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom6-设备在线","dpDesc":"1-设备在线，0-无效","enbaleFlag":1},{"regKey":"1_5001","dpId":33,"unitId":1,"regNo":5001,"byteNo":0,"bitNo":10,"bitLen":3,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom10~bitFrom12-开关机状态","dpDesc":"0-停机，1-运行，2-保护， 3-待机，4-启过","enbaleFlag":1},{"regKey":"1_5002","dpId":34,"unitId":1,"regNo":5002,"byteNo":0,"bitNo":8,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom8-孤岛使能状态","dpDesc":"1-使能，0-不使能","enbaleFlag":1},{"regKey":"1_5005","dpId":35,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-市电电压异常","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":36,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-端口电压异常","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":37,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-交流过流故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":38,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":3,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom3-模块故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":39,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom4-电网不平衡","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":40,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom5-电网相序反","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":41,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom6-孤岛故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":42,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":7,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom7-逆变器短路","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":43,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":8,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom8-交流接地故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":44,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":9,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom9-市电缺零故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":45,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":10,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom10-电网锁相失败","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":46,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":11,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom11-内部环境温度过温","dpDesc":"","enbaleFlag":1},{"regKey":"1_5005","dpId":47,"unitId":1,"regNo":5005,"byteNo":0,"bitNo":12,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom12-环温降额","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":48,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-EPO","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":49,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-软件版本错误","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":50,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-硬件版本错误","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":51,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom5-CAN通信故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":52,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom6-15V辅源故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":53,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":7,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom7-风扇故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":54,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":8,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom8-母线电压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":55,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":10,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom10-母线电压不平衡","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":56,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":11,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom11-交流软启动失败","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":57,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":12,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom12-交流继电器短路","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":58,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":13,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom13-AC电压异常","dpDesc":"","enbaleFlag":1},{"regKey":"1_5006","dpId":59,"unitId":1,"regNo":5006,"byteNo":0,"bitNo":15,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom15-散热器过温","dpDesc":"","enbaleFlag":1},{"regKey":"1_5007","dpId":60,"unitId":1,"regNo":5007,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-输出过载超时","dpDesc":"","enbaleFlag":1},{"regKey":"1_5007","dpId":61,"unitId":1,"regNo":5007,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-逆变软启动失败","dpDesc":"","enbaleFlag":1},{"regKey":"1_5007","dpId":62,"unitId":1,"regNo":5007,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-交流继电器开路","dpDesc":"","enbaleFlag":1},{"regKey":"1_5008","dpId":63,"unitId":1,"regNo":5008,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-EEPROM1读取错误","dpDesc":"","enbaleFlag":1},{"regKey":"1_5008","dpId":64,"unitId":1,"regNo":5008,"byteNo":0,"bitNo":3,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom3-逆变器过载","dpDesc":"","enbaleFlag":1},{"regKey":"1_5009","dpId":65,"unitId":1,"regNo":5009,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-直流充电","dpDesc":"","enbaleFlag":1},{"regKey":"1_5009","dpId":66,"unitId":1,"regNo":5009,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-直流放电","dpDesc":"","enbaleFlag":1},{"regKey":"1_5009","dpId":67,"unitId":1,"regNo":5009,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-直流充满","dpDesc":"","enbaleFlag":1},{"regKey":"1_5009","dpId":68,"unitId":1,"regNo":5009,"byteNo":0,"bitNo":3,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom3-直流放空","dpDesc":"","enbaleFlag":1},{"regKey":"1_5009","dpId":69,"unitId":1,"regNo":5009,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom4-故障状态","dpDesc":"","enbaleFlag":1},{"regKey":"1_5009","dpId":70,"unitId":1,"regNo":5009,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom5-告警状态","dpDesc":"","enbaleFlag":1},{"regKey":"1_5009","dpId":71,"unitId":1,"regNo":5009,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom6-均充超时","dpDesc":"","enbaleFlag":1},{"regKey":"1_5010","dpId":72,"unitId":1,"regNo":5010,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFromO-BMS电压传感器故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5010","dpId":73,"unitId":1,"regNo":5010,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-BMS温度传感器故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5010","dpId":74,"unitId":1,"regNo":5010,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-BMS内部通信故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5010","dpId":75,"unitId":1,"regNo":5010,"byteNo":0,"bitNo":3,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom3-BMS输入过压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5010","dpId":76,"unitId":1,"regNo":5010,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom4-BMS输入反接故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5010","dpId":77,"unitId":1,"regNo":5010,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom5-BMS继电器检测故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5010","dpId":78,"unitId":1,"regNo":5010,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom6-BMS通信故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":79,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-BMS电池单体低压告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":80,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-BMS电池单体高压告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":81,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-BMS电池组放电低压告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":82,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":3,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom3-BMS电池组充电高压告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":83,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom4-BMS电池组充电低温告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":84,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom5-BMS电池组充电高温告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":85,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom6-BMS电池组放电低温告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":86,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":7,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom7-BMS电池组放电高温告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":87,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":8,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom8-BMS电池组充电过流告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":88,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":9,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom9-BMS电池组放电过流告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":89,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":10,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom10-BMS单板低压告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5011","dpId":90,"unitId":1,"regNo":5011,"byteNo":0,"bitNo":11,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom11-BMS单板高压告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":91,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-BMS电池单体低压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":92,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-BMS电池单体高压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":93,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-BMS电池组放电低压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":94,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":3,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom3-BMS电池组充电高压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":95,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom4-BMS电池组充电低温故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":96,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom5-BMS电池组充电高温故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":97,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom6-BMS电池组放电低温故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":98,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":7,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom7-BMS电池组放电高温故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":99,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":8,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom8-BMS电池组充电过流故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":100,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":9,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom9-BMS电池组放电过流故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":101,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":10,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom10-BMS单板低压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5012","dpId":102,"unitId":1,"regNo":5012,"byteNo":0,"bitNo":11,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom11-BMS单板高压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5013","dpId":103,"unitId":1,"regNo":5013,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-直流输入过压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5013","dpId":104,"unitId":1,"regNo":5013,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-直流输入欠压故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5013","dpId":105,"unitId":1,"regNo":5013,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-直流接地故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5014","dpId":106,"unitId":1,"regNo":5014,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-直流软启失败","dpDesc":"","enbaleFlag":1},{"regKey":"1_5014","dpId":107,"unitId":1,"regNo":5014,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom1-直流继电器短路","dpDesc":"","enbaleFlag":1},{"regKey":"1_5014","dpId":108,"unitId":1,"regNo":5014,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom2-直流继电器开路","dpDesc":"","enbaleFlag":1},{"regKey":"1_5014","dpId":109,"unitId":1,"regNo":5014,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom4-母线软启动失败","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":110,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFromO-RS485通信故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":111,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom4-电池DOD","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":112,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom5-电池温度故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":113,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom6-电池EOD","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":114,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":7,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom7-电池均充超时","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":115,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":8,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom8-电池过功率故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":116,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":9,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom9-直流反接故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":117,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":10,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom10-无电池故障","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":118,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":11,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom11-直流输入低压告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5015","dpId":119,"unitId":1,"regNo":5015,"byteNo":0,"bitNo":12,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom12-直流输入高压告警","dpDesc":"","enbaleFlag":1},{"regKey":"1_5016","dpId":120,"unitId":1,"regNo":5016,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"bit","lab":"bitFrom0-直流电流过流","dpDesc":"","enbaleFlag":1},{"regKey":"1_7201","dpId":121,"unitId":1,"regNo":7201,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"输出电压等级","dpDesc":"0-380V;1-400V;2-480V","enbaleFlag":1},{"regKey":"1_7202","dpId":122,"unitId":1,"regNo":7202,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"输出频率等级","dpDesc":"0-50Hz;1-60Hz","enbaleFlag":1},{"regKey":"1_7203","dpId":123,"unitId":1,"regNo":7203,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"输出电压体制","dpDesc":"1-单相;3-三相三线制3P3W;4-三相四线制3P4W","enbaleFlag":1},{"regKey":"1_7207","dpId":124,"unitId":1,"regNo":7207,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"序列号：年+月","dpDesc":"0x0000~0xffff","enbaleFlag":1},{"regKey":"1_7208","dpId":125,"unitId":1,"regNo":7208,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"序列号：日+流水号","dpDesc":"0x0000~0xffff","enbaleFlag":1},{"regKey":"1_7300","dpId":126,"unitId":1,"regNo":7300,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"设备充电电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_7301","dpId":127,"unitId":1,"regNo":7301,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"AB相线电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_7302","dpId":128,"unitId":1,"regNo":7302,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"BC相线电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_7303","dpId":129,"unitId":1,"regNo":7303,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"CA相线电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_7304","dpId":130,"unitId":1,"regNo":7304,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"A相输出电流","dpDesc":"","enbaleFlag":1},{"regKey":"1_7305","dpId":131,"unitId":1,"regNo":7305,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"B相输出电流","dpDesc":"","enbaleFlag":1},{"regKey":"1_7306","dpId":132,"unitId":1,"regNo":7306,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"C相输出电流","dpDesc":"","enbaleFlag":1},{"regKey":"1_7307","dpId":133,"unitId":1,"regNo":7307,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"A相电网频率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7308","dpId":134,"unitId":1,"regNo":7308,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"B相电网频率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7309","dpId":135,"unitId":1,"regNo":7309,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"C相电网频率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7310","dpId":136,"unitId":1,"regNo":7310,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"A相有功功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7311","dpId":137,"unitId":1,"regNo":7311,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"B相有功功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7312","dpId":138,"unitId":1,"regNo":7312,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"C相有功功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7313","dpId":139,"unitId":1,"regNo":7313,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"A相无功功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7314","dpId":140,"unitId":1,"regNo":7314,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"B相无功功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7315","dpId":141,"unitId":1,"regNo":7315,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"C相无功功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7316","dpId":142,"unitId":1,"regNo":7316,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"A相视在功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7317","dpId":143,"unitId":1,"regNo":7317,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"B相视在功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7318","dpId":144,"unitId":1,"regNo":7318,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"C相视在功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7319","dpId":145,"unitId":1,"regNo":7319,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"A相功率因数","dpDesc":"","enbaleFlag":1},{"regKey":"1_7320","dpId":146,"unitId":1,"regNo":7320,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"B相功率因数","dpDesc":"","enbaleFlag":1},{"regKey":"1_7321","dpId":147,"unitId":1,"regNo":7321,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"C相功率因数","dpDesc":"","enbaleFlag":1},{"regKey":"1_7322","dpId":148,"unitId":1,"regNo":7322,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"三相总有功功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7323","dpId":149,"unitId":1,"regNo":7323,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"三相总无功功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7324","dpId":150,"unitId":1,"regNo":7324,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"三相总视在功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7325","dpId":151,"unitId":1,"regNo":7325,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"三相总功率因数","dpDesc":"","enbaleFlag":1},{"regKey":"1_7326","dpId":152,"unitId":1,"regNo":7326,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT32","dpType":"UINT32","lab":"交流有功充电电量","dpDesc":"","enbaleFlag":1},{"regKey":"1_7328","dpId":153,"unitId":1,"regNo":7328,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT32","dpType":"UINT32","lab":"交流有功放电电量","dpDesc":"","enbaleFlag":1},{"regKey":"1_7333","dpId":154,"unitId":1,"regNo":7333,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"正母线电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_7334","dpId":155,"unitId":1,"regNo":7334,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"负母线电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_7335","dpId":156,"unitId":1,"regNo":7335,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"有功功率期望","dpDesc":"-30.0~30.0kW","enbaleFlag":1},{"regKey":"1_7336","dpId":157,"unitId":1,"regNo":7336,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"无功功率期望","dpDesc":"-30.0~30.0kVar","enbaleFlag":1},{"regKey":"1_7341","dpId":158,"unitId":1,"regNo":7341,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"直流功率","dpDesc":"","enbaleFlag":1},{"regKey":"1_7342","dpId":159,"unitId":1,"regNo":7342,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"直流电压","dpDesc":"","enbaleFlag":1},{"regKey":"1_7343","dpId":160,"unitId":1,"regNo":7343,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"INT16","dpType":"INT16","lab":"直流电流","dpDesc":"","enbaleFlag":1},{"regKey":"1_7344","dpId":161,"unitId":1,"regNo":7344,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT32","dpType":"UINT32","lab":"直流充电电量","dpDesc":"","enbaleFlag":1},{"regKey":"1_7346","dpId":162,"unitId":1,"regNo":7346,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT32","dpType":"UINT32","lab":"直流放电电量","dpDesc":"","enbaleFlag":1},{"regKey":"1_7400","dpId":163,"unitId":1,"regNo":7400,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"电池组电压","dpDesc":"BMS上传","enbaleFlag":1},{"regKey":"1_7401","dpId":164,"unitId":1,"regNo":7401,"byteNo":0,"bitLen":0,"rate":0.01,"decLen":2,"dataType":"UINT16","dpType":"UINT16","lab":"电池组电流","dpDesc":"BMS上传","enbaleFlag":1},{"regKey":"1_7402","dpId":165,"unitId":1,"regNo":7402,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"电池环境温度","dpDesc":"BMS上传","enbaleFlag":1},{"regKey":"1_7403","dpId":166,"unitId":1,"regNo":7403,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"电池SOC","dpDesc":"","enbaleFlag":1},{"regKey":"1_7404","dpId":167,"unitId":1,"regNo":7404,"byteNo":0,"bitLen":0,"rate":1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"电池SOH","dpDesc":"","enbaleFlag":1},{"regKey":"1_7405","dpId":168,"unitId":1,"regNo":7405,"byteNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"INT16","dpType":"INT16","lab":"环境温度","dpDesc":"","enbaleFlag":1},{"regKey":"2_3","dpId":169,"unitId":2,"regNo":3,"byteNo":0,"bitLen":0,"rate":1,"decLen":0,"dataType":"INT16","dpType":"INT16","lab":"PT变比","dpDesc":"","enbaleFlag":1},{"regKey":"2_4","dpId":170,"unitId":2,"regNo":4,"byteNo":0,"bitLen":0,"rate":1,"decLen":0,"dataType":"INT16","dpType":"INT16","lab":"CT变比","dpDesc":"","enbaleFlag":1},{"regKey":"2_34","dpId":171,"unitId":2,"regNo":34,"byteNo":0,"bitNo":9,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"DI1","dpDesc":"","enbaleFlag":1},{"regKey":"2_34","dpId":172,"unitId":2,"regNo":34,"byteNo":0,"bitNo":10,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"DI2","dpDesc":"","enbaleFlag":1},{"regKey":"2_34","dpId":173,"unitId":2,"regNo":34,"byteNo":0,"bitNo":11,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"DI3","dpDesc":"","enbaleFlag":1},{"regKey":"2_34","dpId":174,"unitId":2,"regNo":34,"byteNo":0,"bitNo":12,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"DI4","dpDesc":"","enbaleFlag":1},{"regKey":"2_34","dpId":175,"unitId":2,"regNo":34,"byteNo":0,"bitNo":13,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"DO1","dpDesc":"","enbaleFlag":1},{"regKey":"2_34","dpId":176,"unitId":2,"regNo":34,"byteNo":0,"bitNo":14,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"DO2","dpDesc":"","enbaleFlag":1},{"regKey":"2_35","dpId":177,"unitId":2,"regNo":35,"byteNo":0,"bitLen":0,"rate":1,"decLen":0,"dataType":"byte","dpType":"byte","lab":"DCT-小数点 I","dpDesc":"","enbaleFlag":1},{"regKey":"2_35","dpId":178,"unitId":2,"regNo":35,"byteNo":1,"bitLen":0,"rate":1,"decLen":0,"dataType":"byte","dpType":"byte","lab":"DPT-小数点 U","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":179,"unitId":2,"regNo":36,"byteNo":1,"bitLen":0,"rate":1,"decLen":0,"dataType":"byte","dpType":"byte","lab":"DPQ-小数点 PQ","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":180,"unitId":2,"regNo":36,"byteNo":0,"bitNo":0,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"符号-Pa","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":181,"unitId":2,"regNo":36,"byteNo":0,"bitNo":1,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"符号-Pb","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":182,"unitId":2,"regNo":36,"byteNo":0,"bitNo":2,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"符号-Pc","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":183,"unitId":2,"regNo":36,"byteNo":0,"bitNo":3,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"符号-P","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":184,"unitId":2,"regNo":36,"byteNo":0,"bitNo":4,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"符号-Qa","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":185,"unitId":2,"regNo":36,"byteNo":0,"bitNo":5,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"符号-Qb","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":186,"unitId":2,"regNo":36,"byteNo":0,"bitNo":6,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"符号-Qc","dpDesc":"","enbaleFlag":1},{"regKey":"2_36","dpId":187,"unitId":2,"regNo":36,"byteNo":0,"bitNo":7,"bitLen":1,"rate":1,"decLen":0,"dataType":"bit","dpType":"bit","lab":"符号-Q","dpDesc":"","enbaleFlag":1},{"regKey":"2_37","dpId":188,"unitId":2,"regNo":37,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Ua","dpDesc":"","enbaleFlag":1},{"regKey":"2_38","dpId":189,"unitId":2,"regNo":38,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Ub","dpDesc":"","enbaleFlag":1},{"regKey":"2_39","dpId":190,"unitId":2,"regNo":39,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Uc","dpDesc":"","enbaleFlag":1},{"regKey":"2_40","dpId":191,"unitId":2,"regNo":40,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Uab","dpDesc":"","enbaleFlag":1},{"regKey":"2_41","dpId":192,"unitId":2,"regNo":41,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Ubc","dpDesc":"","enbaleFlag":1},{"regKey":"2_42","dpId":193,"unitId":2,"regNo":42,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Uca","dpDesc":"","enbaleFlag":1},{"regKey":"2_43","dpId":194,"unitId":2,"regNo":43,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Ia","dpDesc":"","enbaleFlag":1},{"regKey":"2_44","dpId":195,"unitId":2,"regNo":44,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Ib","dpDesc":"","enbaleFlag":1},{"regKey":"2_45","dpId":196,"unitId":2,"regNo":45,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Ic","dpDesc":"","enbaleFlag":1},{"regKey":"2_46","dpId":197,"unitId":2,"regNo":46,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Pa","dpDesc":"","enbaleFlag":1},{"regKey":"2_47","dpId":198,"unitId":2,"regNo":47,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Pb","dpDesc":"","enbaleFlag":1},{"regKey":"2_48","dpId":199,"unitId":2,"regNo":48,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Pc","dpDesc":"","enbaleFlag":1},{"regKey":"2_49","dpId":200,"unitId":2,"regNo":49,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"P","dpDesc":"","enbaleFlag":1},{"regKey":"2_50","dpId":201,"unitId":2,"regNo":50,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Qa","dpDesc":"","enbaleFlag":1},{"regKey":"2_51","dpId":202,"unitId":2,"regNo":51,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Qb","dpDesc":"","enbaleFlag":1},{"regKey":"2_52","dpId":203,"unitId":2,"regNo":52,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Qc","dpDesc":"","enbaleFlag":1},{"regKey":"2_53","dpId":204,"unitId":2,"regNo":53,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Q","dpDesc":"","enbaleFlag":1},{"regKey":"2_54","dpId":205,"unitId":2,"regNo":54,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"PFa","dpDesc":"","enbaleFlag":1},{"regKey":"2_55","dpId":206,"unitId":2,"regNo":55,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"PFb","dpDesc":"","enbaleFlag":1},{"regKey":"2_56","dpId":207,"unitId":2,"regNo":56,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"PFc","dpDesc":"","enbaleFlag":1},{"regKey":"2_57","dpId":208,"unitId":2,"regNo":57,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"PF","dpDesc":"","enbaleFlag":1},{"regKey":"2_58","dpId":209,"unitId":2,"regNo":58,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Sa","dpDesc":"","enbaleFlag":1},{"regKey":"2_59","dpId":210,"unitId":2,"regNo":59,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Sb","dpDesc":"","enbaleFlag":1},{"regKey":"2_60","dpId":211,"unitId":2,"regNo":60,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"Sc","dpDesc":"","enbaleFlag":1},{"regKey":"2_61","dpId":212,"unitId":2,"regNo":61,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"S","dpDesc":"","enbaleFlag":1},{"regKey":"2_62","dpId":213,"unitId":2,"regNo":62,"byteNo":0,"bitNo":0,"bitLen":0,"rate":0.1,"decLen":1,"dataType":"UINT16","dpType":"UINT16","lab":"频率FR","dpDesc":"","enbaleFlag":1},{"regKey":"2_63","dpId":214,"unitId":2,"regNo":63,"byteNo":0,"bitNo":0,"bitLen":0,"rate":1,"decLen":0,"dataType":"UINT32","dpType":"UINT32","lab":"吸收二次有功电度","dpDesc":"","enbaleFlag":1},{"regKey":"2_65","dpId":215,"unitId":2,"regNo":65,"byteNo":0,"bitNo":0,"bitLen":0,"rate":1,"decLen":0,"dataType":"UINT32","dpType":"UINT32","lab":"释放二次有功电度","dpDesc":"","enbaleFlag":1},{"regKey":"2_67","dpId":216,"unitId":2,"regNo":67,"byteNo":0,"bitNo":0,"bitLen":0,"rate":1,"decLen":0,"dataType":"UINT32","dpType":"UINT32","lab":"感性二次有功电度","dpDesc":"","enbaleFlag":1},{"regKey":"2_69","dpId":217,"unitId":2,"regNo":69,"byteNo":0,"bitNo":0,"bitLen":0,"rate":1,"decLen":0,"dataType":"UINT32","dpType":"UINT32","lab":"容性二次有功电度","dpDesc":"","enbaleFlag":1}]
        self.decodeValues ={}

    def start(self):
        try:
            # connect 
            #   send
            #   recv
            #   decode
            self.connect()            
            while True: 
                connFlag = self.isConnected()
                if connFlag:
                    for task in self.tasks:
                        self.cmdNo = self.cmdNo +1 
                        if self.cmdNo>= 0xfffa :
                            self.cmdNo = 1
                        unit = task["unit"]
                        code = task["code"]
                        start = task["start"]
                        count = task["count"]
                        self.readRegisterLoop(unit , code , start , count)
                    self.decode()
                    #self.write2InfluxDB()
                    self.write2InfluxDBv1x()
                else:
                    break
        except Exception as er:
            print(er)
    def connect(self): 
        try:
            addr = (self.host , self.port)
            self.skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.skt.settimeout(5)
            self.skt.connect(addr) 
        except Exception as er: 
            print(er)    
    def isConnected(self):
        res = False
        try:
            res = self.skt!=None
            if res :
                res = not (self.skt._closed)
        except Exception as er:
            res = False
            print(er)    
        return res
    def readRegister(self , unit , code , start , count):
        res = False
        try:
            byteStart = start.to_bytes(2,'big')
            byteCount = count.to_bytes(2,'big')
            cmdBytes = self.cmdNo -1 
            byteNo = cmdBytes.to_bytes(2, byteorder='big')
            cmdBytes = bytearray([
                byteNo[0],byteNo[1],0x00,0x00,0x00,0x06,unit,code,
                byteStart[0] , byteStart[1] ,
                byteCount[0] , byteCount[1] 
            ])
            self.skt.send(cmdBytes)
            print('send:')
            print(cmdBytes)
            time.sleep(0.1)
            recvBytes , addr = self.skt.recvfrom(1024)
            print(recvBytes)
            #print('recv:')
            #print(recvBytes)
            flag = len(recvBytes)>8 
            if flag:
                flag = (recvBytes[7] == code) and (recvBytes[8]==count*2)
            if flag :
                offset =0 
                while offset<count:
                    pos = 2 * offset
                    regKey = str(unit)+"_"+str(start + offset)
                    regInfo = {
                        "regKey": regKey,
                        "unit": unit ,
                        "regAddr": start + offset ,
                        "hi":recvBytes[pos],
                        "low":recvBytes[pos + 1]
                    }
                    offset = offset + 1
                    self.registers[regKey] = regInfo
                res = True
                #print('communication success.'+str(unit)+"_"+str(start)+":"+str(count))
            else:
                pass
                #print('communication error.'+str(unit)+"_"+str(start)+":"+str(count))
        except Exception as er:            
            res = False
            print('readRegister error.')
            print(er)    
        return res
    def readRegisterLoop(self , unit , code , start , count): 
        try:
            c =0
            flag = self.readRegister(unit,code,start,count)
            while c<3 and not flag:
                time.sleep(0.1)
                c = c+1
                flag = self.readRegister(unit,code,start,count)    
            if c>=3 and not flag:
                print("---------------------")
                print('error.'+str(unit)+"_"+str(start)+":"+str(count))+"by"+str(code)
                print("---------------------")

        except Exception as er:
            res = False
    def decode(self ): 
        try:
            regKeys = self.registers.keys()
            for dp in self.dpList:
                try:
                    regKey = dp["regKey"] 
                    dpKey = regKey+"_"+ str(dp["dpId"])
                    if regKey in regKeys:
                        regInfo = self.registers[regKey]
                        dpKeys = dp.keys()
                        valInfo ={
                            "dpId": dp["dpId"],
                            "unit" : regInfo["unit"] ,
                            "regAddr" : regInfo["regAddr"] ,
                            "dpKey": dpKey,
                            "regkey": regKey,
                            "lab": dp["lab"]
                        }                         
                        dpType = (dp["dpType"]).lower()                        
                        decodeFlag = False
                        if dpType=='bit' and 'bitNo' in dpKeys:
                            bitNo = dp["bitNo"]
                            bv = regInfo["low"]
                            if dp['bitNo']>=8:
                                bv = regInfo["hi"]
                                bitNo = bitNo - 8
                            bv = bv >> (7-bitNo)
                            bv = bv & 0x01
                            valInfo["val"] = bv
                            decodeFlag = True
                        elif dpType=="bitbyte":
                            bitNo = dp["bitNo"]
                            bitLen = dp["bitLen"]
                            tmp =  bin(regInfo["low"])[2:]+ bin(regInfo["hi"])[2:]
                            tmp = tmp[bitNo:bitNo+bitLen]
                            bv = int(tmp,2)
                            valInfo["val"] = bv
                            decodeFlag = True
                        elif dpType=="byte":
                            bv = regInfo["low"]
                            if dp["byteNo"]>0:
                                bv = regInfo["hi"]
                            valInfo["val"] = bv
                            decodeFlag = True
                        elif dpType=="int16":
                            tmp= bytearray([regInfo["low"],regInfo["hi"]])
                            bv= int.from_bytes(tmp ,byteorder='big')
                            valInfo["val"] = bv
                            decodeFlag = True
                        elif dpType=="uint16":
                            tmp= bytearray([regInfo["low"],regInfo["hi"]])
                            bv= struct.unpack(">H" , tmp)
                            valInfo["val"] = bv[0]
                            decodeFlag = True
                        elif dpType=="uint32":
                            nextRegAddr = regInfo["regAddr"]+1
                            nextRegKey = str(regInfo["unit"])+"_"+str(nextRegAddr)
                            if nextRegKey in regKeys:
                                regInfoNext = self.registers[nextRegKey]
                                tmp= bytearray([regInfo["low"],regInfo["hi"],regInfoNext["low"],regInfoNext["hi"]])
                                bv= struct.unpack(">L" , tmp)
                                valInfo["val"] = bv[0]
                                decodeFlag = True
                        if decodeFlag:
                            valInfo["time"] = time.time()
                            self.setDecodeValue(valInfo)
                            print(valInfo)
                        else:
                            print('decode faild.'+dpKey)
                    else:
                        print("data point regKey error."+str(dp["dpId"])+"  . regKey:"+ regKey)
                except Exception as err:
                    print(err)
        except Exception as er:
            res = False
            print(er)  
    def setDecodeValue(self , valInfo ): 
        try: 
            dpKey = valInfo["dpKey"]
            self.decodeValues[dpKey] = valInfo
        except Exception as er: 
            print(er)     
    def saveValues(self ): 
        try:
            data = json.dumps(self.decodeValues,indent=4,ensure_ascii=False)
            fn = self.valueFilePath+"/pcs_dict_"+str(int(time.time()*1000))+".txt"
            with open(fn,'w') as f:
                f.write(data)
            listData = list(self.decodeValues.values())
            data = json.dumps(listData,indent=4,ensure_ascii=False)
            fn = self.valueFilePath+"/pcs_list_"+str(int(time.time()*1000))+".txt"
            with open(fn,'w') as f:
                f.write(data)
            fn = self.valueFilePath+"/pcs_real.txt"
            s = ""
            for d in listData:
                s = s+str(d["dpId"])+","+str(d["val"])+";"
            with open(fn,'w') as f:
                f.write(s)
        except Exception as er: 
            print(er)     
    def post2InfluxDB(self):
        try:
            headers = {
                'Authorization': 'Bearer ' + self.dbToken,
                'Content-Type': 'application/json',
            }
            current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            listData = list(self.decodeValues.values())
            dpList = []
            for dp in listData:
                dpId = dp["dpId"]
                unit = dp["unit"]
                regAddr = dp["regAddr"]
                value = dp["val"] 
                dpItem = {
                    "measurement": self.dbMeasurement,
                    "tags": {"dpId": dpId , "unit":unit , "regAddr":regAddr },
                    "fields": {"value": value},
                    "time": current_time
                }
                dpList.append(dpItem)
            influxdb_url= "http://"+self.dbHost+":"+str(self.dbPort)+"/"
            response = requests.post(influxdb_url + '/api/v2/write', json=dpList, headers=headers)
            if response.status_code != 200:
                print("Error writing data to InfluxDB:", response.text)
            else:
                print('notigy success')
        except Exception as er :
            print(er)
    def getInfluxDBDatapoints(self):
        res = {
            "headers":{},
            "dataPoints":"",
            "dpNum":0,
            "url":""
        };
        try:
            headers = {
                'Authorization': 'Bearer ' + self.dbToken,
                'Content-Type': 'application/json',
            }
            res["headers"] = headers
            current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            t = int((time.time()-8*3600)*1000*1000*1000)
            listData = list(self.decodeValues.values()) 
            datas=""            
            for dp in listData:
                dpId = dp["dpId"]
                unit = dp["unit"]
                regAddr = dp["regAddr"]
                value = dp["val"] 

                item = 'rePolicy_1h.' +self.dbMeasurement
                item = item +",dId="+str(dpId)
                item = item +",u="+str(unit)
                item = item +",r="+str(regAddr)

                item = item+" v="+str(value)
                #item = item+" "+str(t)
                item = item +"\n"

                datas = datas + item
            res["dataPoints"] = datas
            res["dpNum"] = len(listData)
            influxdb_url= "http://"+self.dbHost+":"+str(self.dbPort) + '/api/v2/write?bucket='+self.dbBucket+"&org="+self.dbOrg
            res["url"] = influxdb_url
        except Exception as er :
            print(er)
        return res
    def getFullDataPoints(self):
        res = "";
        try:
            item = 'rePolicy_1h.pcsFull,flag=hhu v=0'
            listData = list(self.decodeValues.values()) 
            for dp in listData:
                dpId = dp["dpId"]
                unit = dp["unit"]
                regAddr = dp["regAddr"]
                value = dp["val"] 
                fieldKey = 'fk_'+str(unit)+'_'+str(regAddr)+'_'+str(dpId)
                item = item +","+fieldKey+"="+str(value)
            res =item
        except Exception as er :
            print(er)
        return res
    def write2InfluxDB(self):
        try:
            info = self.getInfluxDBDatapoints()
            headers = info["headers"]
            url = info["url"]
            datas = info["dataPoints"]
            resp = requests.post(url=url , headers=headers , data=datas)
            print(resp)
        except Exception as er:
            print(er)
    def write2InfluxDBv1x(self):
        try:
            dataPoints = self.getFullDataPoints()
            self.influxDBClient.writeDatapoints(dataPoints)
        except Exception as er:
            print(er)

collector = TModbusCollecter()
collector.start() 